package model;

import java.util.HashMap;

/**
 * The look up table model class
 * 
 * This class is used to model the look up table to hold
 * ip address and ports of each user online. Every time a user
 * comes online, the lookup table is updated with user's information
 * @author Sukhjinder K. Narula
 * @since	June 2013
 */
public class LookUpTable {
	/**
	 * Hashmap which will contain username and a hashmap 
	 * mapping ip address and port for the user
	 */
	HashMap<String, HashMap<String, String>> lut;
	
	/**
	 * Constructor to initialize the empty hashmap 
	 */
	public LookUpTable(){
		lut = new HashMap<String, HashMap<String, String>>();		
	}

	/**
	 * Getter method to return lut hashmap
	 * @return lut: hashmap 
	 */
	public HashMap<String, HashMap<String, String>> getLut() {
		return lut;
	}

	/**
	 * Setter method to set the hashmap object
	 * @param lut: hasmap
	 */
	public void setLut(HashMap<String, HashMap<String, String>> lut) {
		this.lut = lut;
	}
	
	/**
	 * Method to add user data i.e. ip address, and port number
	 */
	public void addUserData(String username, String ipAddress, String port) {
		HashMap<String, String> info = new HashMap<String, String>();
		info.put("IpAddress", ipAddress);
		info.put("Port", port);
		lut.put(username, info);
	}	
}
